# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=tfsec
pkgver=v0.63.1.r408.gb692c20b6
pkgrel=1
pkgdesc='Security scanner for your Terraform code.'
arch=('x86_64' 'aarch64')
groups=('blackarch' 'blackarch-defensive' 'blackarch-scanner')
url='https://github.com/aquasecurity/tfsec'
license=('MIT')
depends=('glibc')
makedepends=('git' 'go')
source=("git+https://github.com/aquasecurity/$pkgname.git")
md5sums=('SKIP')

pkgver() {
  cd $pkgname

  git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cd "$pkgname/cmd/$pkgname"

  GOPATH="$srcdir" go mod download
  GOPATH="$srcdir" go build \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-s -w" \
    -o $pkgname .

}

package() {
  cd $pkgname

  install -Dm 755 "cmd/$pkgname/$pkgname" "$pkgdir/usr/bin/$pkgname"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md
}

